﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using AP.Framework.Infrastructure.Repositories;
using AP.Framework.Infrastructure.Database;
using AP.Framework.Infrastructure.Repositories.IRepositories;
using ApCMS.Models;
namespace ApCMS.Controllers
{
    public class HomeController : Controller
    {

        IProduct _product;
        ILink _links;
        public HomeController(
                              IProduct product,
                              ILink links
                              )
        {
            _product = product;
            _links = links;
        }

        public ActionResult Index()
        {
            HomeModel model = new HomeModel();
            model.ProductList = _product.GetAll().OrderBy(p => p.Sequence).Take(20).ToList();
            model.LinkList = _links.GetAll().OrderBy(p => p.Sequence).Take(20).ToList();
            return View(model);
        }

        public ActionResult About()
        {
            return View();
        }
        public ActionResult SetThemes(string themes)
        {
            HttpCookie cookie = new HttpCookie("themesName");
            cookie.Value = themes;
            Response.Cookies.Add(cookie);
            return RedirectToAction("Index");
           
        }
    }
}
